import { VariableType } from '@/views/editor/components/global-variable/config';
import { NodeType } from '@jl/behavior-designer/src/components/behavior-designer/service';

/**
 * 流程节点自定义属性
 */
export interface IBehaviorTaskProp {
  type: VariableType;
  label: string;
  value: any;
}

/**
 * 流程节点
 */
export interface IBehaviorTask {
  type: string;
  label: string;
  nodeType: NodeType;
  icon?: string;
  description: string;
  props: IBehaviorTaskProp[];
}

/**
 * 流程控制节点
 */
export const taskFlowControl: IBehaviorTask[] = [
  {
    type: 'Sequence',
    label: '串行执行节点',
    nodeType: 'inout',
    icon: '',
    description: '',
    props: [],
  },
  {
    type: 'Parallel',
    label: '并行执行节点',
    description: '',
    icon: '',
    nodeType: 'inout',
    props: [],
  },
  {
    type: 'Selector',
    label: '串行选择节点',
    nodeType: 'inout',
    icon: '',
    description: '',
    props: [],
  },
  {
    type: 'ParallelSelector',
    label: '并行选择节点',
    nodeType: 'inout',
    icon: '',
    description: '',
    props: [],
  },
  {
    type: 'Repeater',
    label: '循环执行节点',
    description: '',
    icon: '',
    nodeType: 'inout',
    props: [],
  },
];

/**
 * 条件判断节点
 */
export const taskCondition: IBehaviorTask[] = [
  {
    type: 'EventListener',
    label: '场景事件监听',
    nodeType: 'inout',
    icon: '',
    description: '用于监听场景事件触发后执行的节点',
    props: [],
  },
  {
    type: 'BoolComparison',
    label: '布尔值比较',
    nodeType: 'out',
    icon: '',
    description: '',
    props: [],
  },
  {
    type: 'NumberComparison',
    label: '数值比较',
    nodeType: 'out',
    icon: '',
    description: '',
    props: [],
  },
  {
    type: 'StringComparison',
    label: '字符串比较',
    nodeType: 'out',
    icon: '',
    description: '',
    props: [],
  },
];

/**
 * 条件判断节点
 */
export const taskAction: IBehaviorTask[] = [
  {
    type: 'Wait',
    label: '定时器',
    nodeType: 'out',
    icon: '',
    description: '用于延迟执行的节点',
    props: [
      {
        type: 'number',
        label: '等待时长',
        value: 0,
      },
    ],
  },
  {
    type: 'ToggleVisible',
    label: '控制显隐',
    nodeType: 'out',
    icon: '',
    description: '',
    props: [],
  },
  {
    type: 'TogglePage',
    label: '页面切换',
    nodeType: 'out',
    icon: '',
    description: '',
    props: [],
  },
  {
    type: 'SetCamera',
    label: '镜头切换',
    nodeType: 'out',
    icon: '',
    description: '',
    props: [],
  },
  {
    type: 'BehaviorTreeReference',
    label: '行为树引用',
    nodeType: 'out',
    icon: '',
    description: '',
    props: [],
  },
  {
    type: 'Log',
    label: '打印日志',
    nodeType: 'out',
    icon: '',
    description: '',
    props: [],
  },
  {
    type: 'SetVariable',
    label: '设置变量',
    nodeType: 'out',
    icon: '',
    description: '',
    props: [],
  },
];

/**
 * 全部节点
 */
export const taskAll = [...taskFlowControl, ...taskCondition, ...taskAction];
